
import Vue from 'vue'
import Vuex from 'vuex'
import { Login } from '../api/user'
import user from './modules/user'
import { saveToken, getToken } from '@/utils/storage.js'
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    list: getToken() || {}
  },
  mutations: {
    setList (state, newList) {
      state.list = newList
      saveToken(newList)
    }
  },
  actions: {
    async getList (context, userInfo) {
      try {
        const res = await Login(userInfo)
        console.log(res)
        context.commit('setList', res.data.data)
      } catch (error) {

      }
    }
  },
  modules: {
    user
  }
})
